package com.ant.storage.service.impl;

import com.ant.storage.common.PageRequest;
import com.ant.storage.common.ResultCode;
import com.ant.storage.common.ResultPage;
import com.ant.storage.handler.AntException;
import com.ant.storage.pojo.GoodsUnits;
import com.ant.storage.mapper.GoodsUnitsMapper;
import com.ant.storage.pojo.Warehouse;
import com.ant.storage.service.IGoodsUnitsService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 * @author melon
 * @since 2022-03-16
 */
@Service
public class GoodsUnitsServiceImpl extends ServiceImpl<GoodsUnitsMapper, GoodsUnits> implements IGoodsUnitsService {
    @Override
    public PageInfo<GoodsUnits> queryPages(PageRequest pageRequest) {
        try {
            PageHelper.startPage(pageRequest.getPageIndex(), pageRequest.getPageSize());
            QueryWrapper<GoodsUnits> wrapper=new QueryWrapper<>();
            wrapper.orderByDesc("id");
            List<GoodsUnits> commodityList = this.baseMapper.selectList(wrapper);
            PageInfo<GoodsUnits> pageInfo = new PageInfo<>(commodityList);
            return  pageInfo;
        } catch (Exception e) {
            throw new AntException(ResultCode.BODY_NOT_MATCH);
        }
    }
}
